package com.midian.service.region.impl;

import java.io.Serializable;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.midian.common.dao.BaseDaoTemplet;
import com.midian.common.dao.OrderHelper;
import com.midian.common.dao.SearchHelper;
import com.midian.common.dao.SearchHelper.Type;
import com.midian.common.exception.BizException;
import com.midian.common.pager.Pager;
import com.midian.model.region.Region;
import com.midian.service.common.BaseService;
import com.midian.service.region.IRegionService;

/**
 * 地区业务实现类
 * @author Mengfh
 *
 */
@Service("regionService")
public class RegionServiceImpl extends BaseService implements IRegionService {
	/**地区DAO*/
	private BaseDaoTemplet<Region> regionDAO;
	
	@Resource(name = "regionDAO")
	public void setRegionDAO(BaseDaoTemplet<Region> regionDAO) {
		this.regionDAO = regionDAO;
	}

	@Override
	public Region add(Region target) throws BizException {
		this.regionDAO.add(target);
		return target;
	}

	@Override
	public void update(Region target) throws BizException {
		this.regionDAO.updateByConvertHql(target);
	}

	@Override
	public void delete(Serializable id) throws BizException {
		this.regionDAO.delete(id);
	}

	@Override
	public void delete(Serializable[] ids) throws BizException {
		this.regionDAO.delete(ids);
	}

	@Override
	public Region get(Serializable id) throws BizException {
		return this.regionDAO.get(id);
	}

	@Override
	public List<Region> showList(Region target, Pager pager, List<OrderHelper> helper) throws BizException {
		return this.regionDAO.find(target, getSearchHelper(), helper, pager);
	}

	@Override
	public void opDelFlag(Serializable[] ids, Integer status) throws BizException {
		this.regionDAO.opDelFlag(ids, status);
	}

	@Override
	protected List<SearchHelper> getSearchHelper() {
		String[] attrs = {};
		Type[] types = {};
		return SearchHelper.getSearchList(attrs, types);
	}
}
